﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Beauty.Module.Pos;
namespace Beauty
{
	public class productCollectionSource: UICollectionViewSource
	{

		List<productItem> listCellProducts;
		 
		int typeCell= 0 ;
		public productCollectionSource (List<productItem> temp, int type)
		{
			listCellProducts = temp;
			typeCell = type;
		}

 
		public override int NumberOfSections (UICollectionView collectionView)
		{
			return 1;
		}
		public override int GetItemsCount (UICollectionView collectionView, int section)
		{
			return listCellProducts.Count;
		}
		public override void ItemHighlighted (UICollectionView collectionView, NSIndexPath indexPath)
		{
			 
			if (typeCell == 0) {
				TopMenuCtrl.contentContainerView.BackgroundColor = UIColor.Black.ColorWithAlpha (0.6f);
				SeviceDetailVCtrl popup = new SeviceDetailVCtrl ();
				popup.View.Layer.CornerRadius = 5f;
				TopMenuCtrl.contentContainerView.Add (popup.View);
				//popup.showAnimation ();

			}
		}
		public override UICollectionViewCell GetCell (UICollectionView collectionView, NSIndexPath indexPath)
		{
			 
			switch (typeCell) {
			case 0:
				 
				var CellGrid = (productCell)collectionView.DequeueReusableCell (new NSString ("gridCell"), indexPath);
				var	CellGridItem = listCellProducts [indexPath.Row];
				CellGrid.Image = CellGridItem.ProductImage;
				return CellGrid;
				 
			case 1:
				var cellTable = (productCellList)collectionView.DequeueReusableCell (new NSString ("tableCell"), indexPath);
				var CellTableItem = listCellProducts [indexPath.Row];
				cellTable.Image = CellTableItem.ProductImage;
				return cellTable;
				 
			default:
				break;
			}

			return null;
		 
		}
			public override UICollectionReusableView GetViewForSupplementaryElement (UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
			{
				if (elementKind == "UICollectionElementKindSectionHeader") {
				 	var headerView = (Header1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Header"), indexPath);
				 	return headerView;
			 	}
	
				if (elementKind == "UICollectionElementKindSectionFooter") {
				 	var footerView = (Footer1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Footer"), indexPath);
				 	return footerView;
				 }
	
				return new UICollectionReusableView (); 
			} 
 
	}
	 
	public class serviecsCollectionSource: UICollectionViewSource
	{

		List<ServiceItem> listCellServices;
	 
		static int typeCell = 0;
		public serviecsCollectionSource (List<ServiceItem> temp,int type)
		{
			listCellServices = temp;
			typeCell = type;
		}
		public override int NumberOfSections (UICollectionView collectionView)
		{
	
			return 1;
		}
		public override int GetItemsCount (UICollectionView collectionView, int section)
		{
			return listCellServices.Count;
		}
		public override void ItemHighlighted (UICollectionView collectionView, NSIndexPath indexPath)
		{
//			//var cell = (serviceCell)collectionView.CellForItem (indexPath) | (servicesCellList)collectionView.CellForItem (indexPath);
//			serviecCell cell;
			if (typeCell!=1) {
				TopMenuCtrl.contentContainerView.BackgroundColor = UIColor.Black.ColorWithAlpha (0.6f);
				SeviceDetailVCtrl popup = new SeviceDetailVCtrl ();
				popup.View.Layer.CornerRadius = 5f;
				TopMenuCtrl.contentContainerView.Add (popup.View);
			}

			//popup.showAnimation ();


		}
		public override UICollectionViewCell GetCell (UICollectionView collectionView, NSIndexPath indexPath)
		{	

			switch (typeCell) {
				case 0:
					var CellGrid = (serviceCell)collectionView.DequeueReusableCell (new NSString ("gridCell"), indexPath);
				var	CellGridItem = listCellServices [indexPath.Row];
					CellGrid.Image = CellGridItem.ServiceImage;
					return CellGrid;
				case 1:
					var cellTable = (servicesCellList)collectionView.DequeueReusableCell (new NSString ("tableCell"), indexPath);
				var CellTableItem = listCellServices [indexPath.Row];
					cellTable.Image = CellTableItem.ServiceImage;
					return cellTable;

				default:
					break;
			}
			return null;
		 
		}
		public override UICollectionReusableView GetViewForSupplementaryElement (UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
		{
			if (elementKind == "UICollectionElementKindSectionHeader") {
				var headerView = (Header1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Header"), indexPath);
				return headerView;
			}

			if (elementKind == "UICollectionElementKindSectionFooter") {
				var footerView = (Footer1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Footer"), indexPath);
				return footerView;
			}

			return new UICollectionReusableView (); 
		} 

	}

	public class packagesCollectionSource: UICollectionViewSource
	{

		List<packageItem> listCellPackages;

		static int typeCell = 0;
		public packagesCollectionSource (List<packageItem> temp, int type )
		{
			listCellPackages = temp;
			typeCell = type;
		}
		public override int NumberOfSections (UICollectionView collectionView)
		{  

			return 1;
		}
		public override int GetItemsCount (UICollectionView collectionView, int section)
		{
			return listCellPackages.Count;
		}
		public override UICollectionViewCell GetCell (UICollectionView collectionView, NSIndexPath indexPath)
		{	

			switch (typeCell) {
			case 0:
				var CellGrid = (packageCell)collectionView.DequeueReusableCell (new NSString ("gridCell"), indexPath);
				var	CellGridItem = listCellPackages [indexPath.Row];
				CellGrid.Image = CellGridItem.PackageImage;
				return CellGrid;
			case 1:
				var cellTable = (packageCellList)collectionView.DequeueReusableCell (new NSString ("tableCell"), indexPath);
				var CellTableItem = listCellPackages [indexPath.Row];
				cellTable.Image = CellTableItem.PackageImage;
				return cellTable;

			default:
				break;
			}
			return null;

		}
		public override UICollectionReusableView GetViewForSupplementaryElement (UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
		{
			if (elementKind == "UICollectionElementKindSectionHeader") {
				var headerView = (Header1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Header"), indexPath);
				return headerView;
			}

			if (elementKind == "UICollectionElementKindSectionFooter") {
				var footerView = (Footer1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Footer"), indexPath);
				return footerView;
			}

			return new UICollectionReusableView (); 
		} 
	}

	public class giftCollectionSource: UICollectionViewSource
	{

		List<giftItem> listCellGift;

		static int typeCell = 0;
		public giftCollectionSource (List<giftItem> temp, int type )
		{
			listCellGift = temp;
			typeCell = type;
		}
		public override int NumberOfSections (UICollectionView collectionView)
		{  

			return 1;
		}
		public override int GetItemsCount (UICollectionView collectionView, int section)
		{
			return listCellGift.Count;
		}
		public override UICollectionViewCell GetCell (UICollectionView collectionView, NSIndexPath indexPath)
		{	

			switch (typeCell) {
			case 0:
				var CellGrid = (giftCell)collectionView.DequeueReusableCell (new NSString ("gridCell"), indexPath);
				var	CellGridItem = listCellGift [indexPath.Row];
				CellGrid.Image = CellGridItem.giftImage;
				return CellGrid;
			case 1:
				var cellTable = (giftCellList)collectionView.DequeueReusableCell (new NSString ("tableCell"), indexPath);
				var CellTableItem = listCellGift [indexPath.Row];
				cellTable.Image = CellTableItem.giftImage;
				return cellTable;

			default:
				break;
			}
			return null;

		}
		public override UICollectionReusableView GetViewForSupplementaryElement (UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
		{
			if (elementKind == "UICollectionElementKindSectionHeader") {
				var headerView = (Header1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Header"), indexPath);
				return headerView;
			}

			if (elementKind == "UICollectionElementKindSectionFooter") {
				var footerView = (Footer1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Footer"), indexPath);
				return footerView;
			}

			return new UICollectionReusableView (); 
		} 
	}
	public class discountCollectionSource: UICollectionViewSource
	{

		List<discountItem> listCellDiscount;

		static int typeCell = 0;
		public discountCollectionSource (List<discountItem> temp, int type )
		{
			listCellDiscount = temp;
			typeCell = type;
		}
		public override int NumberOfSections (UICollectionView collectionView)
		{  

			return 1;
		}
		public override int GetItemsCount (UICollectionView collectionView, int section)
		{
			return listCellDiscount.Count;
		}
		public override UICollectionViewCell GetCell (UICollectionView collectionView, NSIndexPath indexPath)
		{	

			switch (typeCell) {
			case 0:
				var CellGrid = (discountCell)collectionView.DequeueReusableCell (new NSString ("gridCell"), indexPath);
				var	CellGridItem = listCellDiscount [indexPath.Row];
				CellGrid.Image = CellGridItem.discountImage;
				return CellGrid;
			case 1:
				var cellTable = (discountCellList)collectionView.DequeueReusableCell (new NSString ("tableCell"), indexPath);
				var CellTableItem = listCellDiscount [indexPath.Row];
				cellTable.Image = CellTableItem.discountImage;
				return cellTable;

			default:
				break;
			}
			return null;

		}
		public override UICollectionReusableView GetViewForSupplementaryElement (UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
		{
			if (elementKind == "UICollectionElementKindSectionHeader") {
				var headerView = (Header1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Header"), indexPath);
				return headerView;
			}

			if (elementKind == "UICollectionElementKindSectionFooter") {
				var footerView = (Footer1)collectionView.DequeueReusableSupplementaryView (elementKind, new NSString ("Footer"), indexPath);
				return footerView;
			}

			return new UICollectionReusableView (); 
		} 
	}

	public class Header1 : UICollectionReusableView
	{



		[Export ("initWithFrame:")]
		public Header1 (System.Drawing.RectangleF frame) : base (frame)
		{
			UISearchBar temp = new UISearchBar( new RectangleF(20, 15, 575, 40));
			temp.Layer.BorderWidth = 0.5f;
			temp.Layer.CornerRadius = 20f;
			//temp.BackgroundColor = UIColor.White ;
			temp.BarTintColor = UIColor.White;
			AddSubview (temp);
		}
	}
	public class Footer1 : UICollectionReusableView
	{

		[Export ("initWithFrame:")]
		public Footer1 (System.Drawing.RectangleF frame) : base (frame)
		{
			UIPageControl temp = new UIPageControl( new RectangleF(80, 15, 450, 30));
			temp.CurrentPageIndicatorTintColor = UIColor.LightGray;
			temp.PageIndicatorTintColor = UIColor.GroupTableViewBackgroundColor;
			temp.Pages = 4; 
			temp.CurrentPage = 0;
			//temp.Layer.BorderColor = UIColor.Black.CGColor;
			//temp.Layer.BorderWidth = 1f;
			AddSubview (temp);
		}
	}
}

